home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
pxewin.zip
/
PXREC.CPP
< prev
next >
Wrap
Text File
|
1992-02-06
|
7KB
|
259 lines
// PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
// PXREC_CPP //
// Contents ----------------------------------------------------------------
//
// This module contains members of the PXRec class for interfacing
// with records in a Paradox table.
//
// End ---------------------------------------------------------------------
// External Reference Name for this Header ---------------------------------
#ifndef PXREC_CPP
#define PXREC_CPP
// End ---------------------------------------------------------------------
// Interface Dependencies --------------------------------------------------
#ifndef PXREC_HPP
#include "pxrec.hpp"
#endif // PXREC_HPP //
// End ---------------------------------------------------------------------
// constructor PXRec //
inline PXRec::PXRec(PPXEngObject my_engobj)
{
EngDataPtr = my_engobj->EngDataPtr;
// Create a record handle
recHandle = new RECORDHANDLE;
// Open the record buffer
if((EngDataPtr->Errors.pxerr = PXRecBufOpen(EngDataPtr->tblHandle,
recHandle)) != PXSUCCESS)
PXError(ENG_ERROR);
else
close_status = OPENED;
}
// Summary -----------------------------------------------------------------
//
// Open record transfer buffer.
//
// Parameters
//
// my_engobj. This is the parent engine object pointer for referencing
// back to the parent object.
//
// Description
//
// 1. Copy the Engine Data Pointer.
//
// 2. Make a new record handle.
// 3. Open a record transfer buffer and the closed_status to OPENED if
// there are no errors.
//
// End ---------------------------------------------------------------------
// destructor PXRec //
inline PXRec::~PXRec()
{
if(close_status == OPENED)
{
if((EngDataPtr->Errors.pxerr = PXRecBufClose(*recHandle))
!= PXSUCCESS)
PXError(ENG_ERROR);
}
delete recHandle;
recHandle = NULL;
}
// Summary -----------------------------------------------------------------
//
// If the record transfer buffer is opened, close it. Delete the record
// handle and set it's pointer to NULL so that if the destructor is
// called again, it won't delete the same pointer again.
//
// End ---------------------------------------------------------------------
// member build of PXRec //
PTStreamable PXRec::build()
{
return new PXRec(streamableInit);
}
TStreamableClass RegPXRec("PXRec",PXRec::build,
__DELTA(PXRec));
// Description -------------------------------------------------------------
//
// When the streamable constructor is called, TStreamable dispatches
// the build member to construct the object. To do this, it must
// know where to find this member functions for the specific class.
// This is the reason for the stream registration.
//
// End ---------------------------------------------------------------------
// member read of PXRec //
inline Pvoid PXRec::read(Ripstream)
{
return this;
}
// Description -------------------------------------------------------------
//
// Nothing is taken from the stream.
//
// End ---------------------------------------------------------------------
// member write of PXRec //
inline void PXRec::write(Ropstream)
{
}
// Description -------------------------------------------------------------
//
// Nothing is put on the stream.
//
// End ---------------------------------------------------------------------
// member Get of PXRec //
inline int PXRec::Get()
{
if((EngDataPtr->Errors.pxerr = PXRecGet(EngDataPtr->tblHandle,
*recHandle)) != PXSUCCESS)
PXError(ENG_ERROR);
return EngDataPtr->Errors.pxerr;
}
// Summary -----------------------------------------------------------------
//
// Gets a record into the record transfer buffer.
//
// Return Value
//
// pxerr. Returns PDOX error status.
//
// End ---------------------------------------------------------------------
// member Update of PXRec //
inline int PXRec::Update()
{
if((EngDataPtr->Errors.pxerr = PXRecUpdate(EngDataPtr->tblHandle,
*recHandle)) != PXSUCCESS)
PXError(ENG_ERROR);
return EngDataPtr->Errors.pxerr;
}
// Summary -----------------------------------------------------------------
//
// Updates the current record in the table from the record transfer
// buffer.
//
// Return Value
//
// pxerr. Returns PDOX error status.
//
// End ---------------------------------------------------------------------
// member RecPrev of PXRec //
inline int PXRec::RecPrev()
{
if((EngDataPtr->Errors.pxerr = PXRecPrev(EngDataPtr->tblHandle))
!= PXSUCCESS)
PXError(ENG_ERROR);
return EngDataPtr->Errors.pxerr;
}
// Summary -----------------------------------------------------------------
//
// Goes to the previous record in the database.
//
// Return Value
//
// pxerr. Returns PDOX error status.
//
// End ---------------------------------------------------------------------
// member RecNext of PXRec //
inline int PXRec::RecNext()
{
if((EngDataPtr->Errors.pxerr = PXRecNext(EngDataPtr->tblHandle))
!= PXSUCCESS)
PXError(ENG_ERROR);
return EngDataPtr->Errors.pxerr;
}
// Summary -----------------------------------------------------------------
//
// Goes to the next record in the database.
//
// Return Value
//
// pxerr. Returns PDOX error status.
//
// End ---------------------------------------------------------------------
// member GoTo of PXRec //
inline int PXRec::GoTo(RECORDNUMBER recNum)
{
if((EngDataPtr->Errors.pxerr = PXRecGoto(EngDataPtr->tblHandle,
recNum)) != PXSUCCESS)
PXError(ENG_ERROR);
return EngDataPtr->Errors.pxerr;
}
// Summary -----------------------------------------------------------------
//
// Goes to a given record number in the database.
//
// Parameters
//
// recNum. Is the record number of the record you wish to go to.
//
// Return Value
//
// pxerr. Returns PDOX error code.
//
// End ---------------------------------------------------------------------
// member PXError of PXRec //
inline void PXRec::PXError(int org)
{
// Call base class error handler
PXEngObject::PXError(org);
// Call the parent handler
EngDataPtr->PXEObjPtr->EngDataPtr->Errors.pxerr =
EngDataPtr->Errors.pxerr;
EngDataPtr->PXEObjPtr->PXError(EngDataPtr->Errors.Origin);
}
// Description -------------------------------------------------------------
//
// Calls the parent error handler if you have an error. This provides
// a centralized error handler for all classes derived from PXEngObject.
//
// End ---------------------------------------------------------------------
#endif // PXREC_CPP //